﻿using System;

namespace WmsApp.UI
{
    public partial class QOutStoreBillDtl : QOutStoreBill, IQueryControl
    {
        public QOutStoreBillDtl()
        {
            InitializeComponent();
        }

        #region IQueryControl Members

        public new string GetCondition()
        {
            string condition = "";
            if (lookUpEditBillState.EditValue != null && !String.IsNullOrEmpty(lookUpEditBillState.EditValue.ToString()))
            {
                condition += (String.Format("  and BillID in ( select BillID from dbo.OutStoreBill where BillState ='{0}')", lookUpEditBillState.EditValue));
            }
            if (lookUpEditGoodsCodeType.EditValue != null && !String.IsNullOrEmpty(lookUpEditGoodsCodeType.EditValue.ToString()))
            {
                condition += (String.Format(" and  NewGoodsCode ='{0}' ", lookUpEditGoodsCodeType.EditValue));
            }
            if (lookUpEditOutStoreType.EditValue != null && !String.IsNullOrEmpty(lookUpEditOutStoreType.EditValue.ToString()))
            {
                condition += (String.Format("  and BillID in ( select BillID from dbo.OutStoreBill where  ExtVarChar1 ='{0}' )", lookUpEditOutStoreType.EditValue));
            }

            if (!String.IsNullOrEmpty(textEditProjectNo.Text))
            {
                condition += (String.Format("   and BillID in ( select BillID from dbo.OutStoreBill where ProjectNo like '%{0}%' ) ", textEditProjectNo.Text));
            }

            if (lookUpEditStoreType.EditValue != null && !String.IsNullOrEmpty(lookUpEditStoreType.EditValue.ToString()))
            {
                condition += (String.Format(" and   StoreTypeCode ='{0}' ", lookUpEditStoreType.EditValue));
            }
            if (lookUpEditUnit.EditValue != null && !String.IsNullOrEmpty(lookUpEditUnit.EditValue.ToString()))
            {
                condition += (String.Format(" and  UnitCode ='{0}' ", lookUpEditUnit.EditValue));
            }

            if (!String.IsNullOrEmpty(this.textEditOutStoreBIllID.Text))
            {
                condition += (String.Format("  and BillID in ( select BillID from dbo.OutStoreBill where  BillID  like '%{0}%' )", textEditOutStoreBIllID.Text));
            }

            if (this.dateEditBillDateFrom.EditValue != null)
            {
                condition += (String.Format(" and BillID in ( select BillID from dbo.OutStoreBill where  BillDate  >= '{0}' )", dateEditBillDateFrom.Text));
            }

            if (this.dateEditBillDateTo.EditValue != null)
            {
                condition += (String.Format("  and BillID in ( select BillID from dbo.OutStoreBill where BillDate  <= '{0}' )", dateEditBillDateTo.Text));
            }

            //库位
            if (!String.IsNullOrEmpty(this.textEditStoreLocation.Text.Trim()))
            {
                condition += (String.Format(" and  StoreLocation  like '%{0}%' ", this.textEditStoreLocation.Text.Trim()));
            }

            if (!String.IsNullOrEmpty(this.textEditPurpose.Text.Trim()))
            {
                condition += (String.Format("  and BillID in ( select BillID from dbo.OutStoreBill where Purpose like '%{0}%' )", this.textEditPurpose.Text.Trim()));
            }
            return condition;
        }

        #endregion
    }
}
